﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WF_QLThuVien.Utilities
{
    public static class CPhatSinhMa
    {       
        /*
        public static string MaTacGia(string tenTG, DateTime time)
        {
            string code = "";
            Random rd = new Random();
            //code = CXuLiChuoi.LayKiTuDauMoiChu(tenTG) + DateTime.Now.ToString("dd/MM/yy") + rd.Next(DateTime.Now.Hour).ToString();
            code = CXuLiChuoi.LayKiTuDauMoiChu(tenTG) + CXuLiChuoi.LayChuoiThoiGian(time) + rd.Next(DateTime.Now.Hour).ToString();
            return code;
        }
*/
        public static List<string> MaSach(string maLoaiSach, int soLuong, DateTime time)
        {
            List<string> code = new List<string>();
            for (int i = 1; i <= soLuong; i++)
            {
                //code.Add(tenTruong + maLoaiSach + DateTime.Now.ToString("dd/MM/yy") + i.ToString());
                code.Add(CVariable.TEN_TRUONG + maLoaiSach + time.ToString("hhmmss") + i.ToString());
            }
            return code;
        }



        public static string MaNXB(string tenNXB, DateTime time)
        {
            string code = "";
            //code = CXuLiChuoi.LayKiTuDauMoiChu(tenNXB) + DateTime.Now.ToString("dd/MM/yy");
            code = CXuLiChuoi.LayKiTuDauMoiChu(tenNXB) + time.ToString("hhmmss");
            return code;
        }

        public static string MaThietBi(string tenTB, DateTime time)
        {
            string code = "";
            //code = tenTB + DateTime.Now.ToString("dd/MM/yy");
            code = tenTB + time.ToString("ddMMyy");
            return code;
        }

        public static string MaLoaiThietBi(string tenLoai)
        {
            string code = "";
            code = CXuLiChuoi.LayKiTuDauMoiChu(tenLoai);
            return code;
        }

        public static string MaLoaiSach(string tenLoai)
        {
            string code = "";
            code = CXuLiChuoi.LayKiTuDauMoiChu(tenLoai);
            return code;
        }

        public static void SoComboBox(int start, int end, ComboBox cbb)
        {
            for (int i = start; i <= end; i++)
            {
                cbb.Items.Add(i);
            }
        }

        public static void ChuoiComboBox(string[] str, ComboBox cbb)
        {
            for (int i = 0; i < str.Length; i++)
            {
                string name = str[i];
                cbb.Items.Add(name);
            }
        }

        public static void ChuoiComboBox(List<string> str, ComboBox cbb)
        {
            for (int i = 0; i < str.Count; i++)
            {
                cbb.Items.Add(str[i]);
            }
        }

        public static string MaDocGia(DateTime dt)
        {
            string code = "D";
            code += dt.ToString("ddMMyy") + dt.ToString("hhmmss");
            return code;
        }

        public static string MaAuto(DateTime dt, string str)
        {
            string code = str;
            Random rd = new Random();
            code += dt.ToString("ddMMyy") + dt.ToString("hhmmss") + rd.Next(dt.Second).ToString();
            return code;
        }

        public static string MaPhieuMuon(DateTime dt)
        {
            string code = "";
            code += dt.ToString("ddMMyy") + dt.ToString("hhmmss");
            return code;
        }
    }
}
